﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/top.jsp"%>
<%@page import="java.lang.Math" %>
<%@page import="java.lang.String" %>
<%@page import="cn.com.generaldata.os.common.Constants" %>
<%@ page import="cn.com.generaldata.os.constant.ReportConstant" %>
<%
String urlm = Constants.METHOD_SHOW_REPORT_DETAIL;
String urlr = Constants.REPORT_OPERATOR_ID;
String urlc = Constants.REPORT_ID;
int commit = Constants.FLAG_COMMITTED;
%>
<c:set var="provinceArea" value="<%=ReportConstant.PROVINCE_AREA_ID%>"></c:set>
<script>document.title="报表审核";</script>
<script src="${baseURL}/static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function clearInput() {
	$("#unitName").val("");
	$("#endingReportDate").val("");
	$("#startingReportDate").val("");
	$("#vsId").val("0");
	$("#repId").val("0");
	$("#createYear").val("");
}
function cshHistory(id,tit){
	//alert(id);
	openWin(tit,"${baseURL}/data/view?id="+id,1000,500);
}
function cshDetail(url,tit){
	openWin(tit,url,1000,550,reload);
}

function changeSys(id){
	$.getJSON("${baseURL}/monitor/changeSys?id="+id, function(data) {
		$("#vsId").empty();
		//alert(data);
		$("#repId").empty();
		$("#vsId").append("<option value='0'>...</option>");
	 	$.each(data, function(i, item) {
            $("#vsId").append( "<option value='" + item.id + "'>" + item.versionSystem + "</option>" );
        });
 });	
}
function changeVs(sysId,vsId) {
	$.getJSON("${baseURL}/monitor/changeRsToData?sysId="+sysId+"&vsId="+vsId, function(data) {
		$("#repId").empty();
		$("#repId").append("<option value='0'>...</option>");
	 	$.each(data, function(i, item) {
            $("#repId").append( "<option id='"+item.newId+"' value='" + item.id + "'>" + item.typeName + "</option>" );
        });
 });
}
function searchYhqy() {
	if(!$("#sysId").val()) {
		layer.alert("请选择报表制度");
		return false;
	}
	if($("#repId").val()==0 || $("#repId").val()== null || $("#repId").val()== "") {
		layer.alert("请选择制度下的报表");
		return false;
	}
	var radius = $("#repId option:selected").attr("id");
	openWin("审核报表","${ctx}/audit/toVerify?checkStatus=1&reporTypeId="+$("#repId").val()+"&startingReportDate="+$("#startingReportDate").val()+"&endingReportDate="+$("#endingReportDate").val()+"&flag=0&newTypeId="+radius+"&year="+$("#createYear").val(),1000,500,reload);

}

function yhqyExp(){
	if(!$("#sysId").val()) {
		layer.alert("请选择报表制度");
		return false;
	}
	if($("#repId").val()==0 || $("#repId").val()== null || $("#repId").val()== "") {
		layer.alert("请选择制度下的报表");
		return false;
	}
	var radius = $("#repId option:selected").attr("id");
	$('#exportForm').attr("action","${ctx}/audit/mutiExport?checkStatus=1&repId="+$("#repId").val()+"&startingReportDate="+$("#startingReportDate").val()+"&endingReportDate="+$("#endingReportDate").val()+"&flag=0&showSum=true&repNewId="+radius+"&year="+$("#createYear").val());
	$("#exportForm").submit();
}

function reload(data) {
    if (data!=null){
    	alert(data);
    }
	
    document.searchForm.submit();
}

function selectAll(checkAllFlag) {
	var checkArray = document.getElementsByName("chk");
	for (var i = 0; i < checkArray.length; i++) {
		checkArray[i].checked = checkAllFlag;
	}
}

function multiPass(ck)
{
	if (jQuery("input[name='chk']:checked").length < 1)
	{
		alert("请选择要审核的报表。");
		return;
	}
	var common=$("#checkComment").val();
	if(ck==3&&common=="")
	{
			alert("请填写审核意见。");
			return;	
	}
	var ids="";
	  var checkboxa = jQuery("input[name='chk']:checked").each(function(){
		  ids+=jQuery(this).val()+",";
	 });
	  var url = "${baseURL}/report/submit";
		var data = "checkStatus="+ck+"&ids="+ids+"&common="+common;

		var loadi;
		$.ajax({
			url: url,
			type: 'post',
			data: data,
			dataType: 'json',
			beforeSend: function(){
				loadi = layer.load('审核中…');
			},
			complete: function(){
				layer.close(loadi);
			},
			success: function(msg){
				reload(msg.message);
			}
		});	
}
</script>
  <table>
   <tbody>
	<tr>
	<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png" align="absmiddle">&nbsp;报表审核</th>
	</tr>
    <tr class="tab_grey">
      <td>
		<form name="searchForm" id="searchForm" action="${baseURL}/audit/init" method="post">
			<input type="hidden" name="p" value="1" />
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表制度
			<select id="sysId" name="sysId" style="width:180px" onchange="changeSys($('#sysId').val());"  class="tab_textbut">
               <c:forEach var="sys" items="${sysList}">
                   <option value="${sys.code}">${sys.codeName}</option>
               </c:forEach>
           </select>
           <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表版本
			<select id="vsId" name="vsId" style="width:120px" onchange="changeVs($('#sysId').val(),$('#vsId').val());"  class="tab_textbut">
			<option value="0">...</option>
               <c:forEach var="vs" items="${vsList}">
                   <option value="${vs.id}">${vs.versionSystem}</option>
               </c:forEach>
           </select>
           <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表
			<select id="repId" name="repId" style="width:250px"  class="tab_textbut">
			<option value="0">...</option>
				<c:forEach var="rep" items="${repList}">
                   <option value="${rep.id}" id="${rep.newId}">${rep.typeName}</option>
                </c:forEach>
           </select>
           	&nbsp;&nbsp;&nbsp;
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />填报单位名称：
			<input type="text" name="unitName" id="unitName" value="${param['unitName']}" size="20"  class="tab_textbut"/>
			<br />
			<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表年份
			<select style="width:70px" id="createYear" name="createYear" onchange="getRep($('#createYear').val(),$('#sysId').val());"  class="tab_textbut">
               <c:forEach var="year" items="${yearList}">
                   <option value="${year}" <c:if test="${curYear == year}">selected</c:if>>${year}</option>
               </c:forEach>
           </select>
           <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />报表时间：起始时间
           <input id="startingReportDate" name="startingReportDate" onfocus="WdatePicker()" class="Wdate" value="${param['startingReportDate']}" type="text"  class="tab_textbut">
           &nbsp;&nbsp;&nbsp;
           <img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />结束时间
           <input id="endingReportDate" name="endingReportDate" onfocus="WdatePicker()" class="Wdate" value="${param['endingReportDate']}" type="text"  class="tab_textbut">
           
			<a class="tab_but" href="#" onclick="searchForm.submit();return false;">查询</a>
			<a class="tab_but" href="#" onclick="clearInput();return false;">清空</a>
	<br/>
			<a class="tab_but02" href="#" onclick="searchYhqy();return false;">报表汇总审核查询</a>
			<a class="tab_but02" href="#" onclick="yhqyExp();return false;">汇总报表导出</a>

			<br/>
		<c:if test="${sessionScope.user.userAreaId eq provinceArea}">
		<img src="${baseURL}/static/images/tab/ico.png" width="20" height="10" />审核意见：
		<textarea id="checkComment" name="checkComment" style="width:350px;"></textarea>
		<a class="tab_but02" href="#" onclick="multiPass(5);return false;">批量审核通过</a>
				<a class="tab_but02" href="#" onclick="multiPass(3);return false;">批量审核驳回</a>
		</c:if>
		</form>
		<script>
		$("#unitName").val("${param['unitName']}");
		$("#createYear").val("${param['createYear']}");
		$("#vsId").val("${param['vsId']}");
		$("#repId").val("${param['repId']}");
		$("#sysId").val("${param['sysId']}");
		$("#startingReportDate").val("${param['startingReportDate']}");
		$("#endingReportDate").val("${param['endingReportDate']}");
		</script>
    </td>
    </tr>
    </tbody>
  </table>
  
  <br />
	<c:if test="${empty obj.operationResult}">
		<b>没有符合条件的记录。</b>
	</c:if>
<c:if test="${not empty obj.operationResult}">
  <table id="listTable">
  <tbody>
    <tr>
    	 <th width="5%"><input type="checkbox" onclick="selectAll(this.checked);"></th>
        <th width="15%">数据报表</th>
		<th width="10%">频率</th>
		<th width="10%">报表年份</th>
		<th width="10%">报出时间</th>
		<th width="20%">报表单位</th>
		<th width="10%">填表人</th>
		<th width="10%">审批历史</th>
		<th width="10%">操作</th>
    </tr>
    <c:forEach var="oneRow" items="${obj.operationResult}">
    		
    <tr>
   <td align="left"><input name="chk" type="checkbox" id="chk" value="${oneRow.id}" /></td>
      	<td align="left">${oneRow.reportName}</td>
		<td align="left">${requestScope.reportTimetype[oneRow.reportTimetype]}</td>
		<td align="left">${oneRow.reportYear}</td>
		<td align="left"><fmt:formatDate value="${oneRow.reportDate}" type="both" pattern="yyyy-MM-dd"/></td>
		<td align="left">${oneRow.reportUnit}</td>
		<td align="left">${oneRow.reportFillAdmin}</td>
		
		<td align="left"><a href="#" onclick="cshHistory('${oneRow.id}','    查看'+'${oneRow.reportUnit}'+'的'+'${oneRow.reportName}'+'的审批历史');">历史</a></td>
		<td align="left"><a href="#" onclick="cshDetail('${baseURL}/reports/service.do?method='+'<%=urlm%>'+'<%=urlr%>'+'${userId}'+'<%=urlc%>'+'${oneRow.id}','  查看'+'${oneRow.reportName}');">详细</a></td>
		
    </tr>
    </c:forEach>
    <tr class="tab_grey">
				<td colspan="9" align="center" valign="middle" class="tab_white">
				<div class="pagination"> 
					<%@ include file="../include/listpage2.jsp"%>
				</div>
				<div class="clear"></div>
				<form action="${ctx}/report/exportReport" method="post" id="exportForm" name="exportForm">
	</form>
				</td>
			</tr>
   </tbody>
  </table>
</c:if>
<%@ include file="/static/include/bottom.jsp"%>
